function postJson(url, json, cb) {
  $.ajax({
    url: url,
    type: "POST",
    headers: {"Content-Type": "application/json;charset=UTF-8"},
    data: JSON.stringify(json),
    success: function (res) {
      cb && cb(null, res);
    },
    error: function (xhr) {
      cb && cb(xhr.responseText);
    }
  });
}

function login(email, password, cb) {
  var url = 'http://192.168.61.47:9999/platform/users/login';
  var json = {email: email, password: password};
  postJson(url, json, cb);
}

function register(email, password, cb) {
  var url = 'http://192.168.61.47:9999/platform/users/';
  var json = {email: email, password: password};
  postJson(url, json, cb);
}